public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}

//题解方法，时间复杂度O(n)
//初始化双指针i，j到数组左右两端
//每次选取短边向内移动
class Solution {
    public int maxArea(int[] height) {
        int i = 0, j = height.length - 1;
        int max = 0;
        while(i < j){
            int area = (j - i) * Math.min(height[i], height[j]);
            if(area > max) max = area;
            if(height[i] < height[j]) i++;
            else j--;
        }
        return max;
    }
}

//时间复杂度O(n^2)，超时
class Solution1 {
    public int maxArea(int[] height) {
        int max = 0;
        for(int i = 0; i < height.length; i++){
            for(int j = i + 1; j < height.length; j++){
                int area = (j - i) * Math.min(height[i], height[j]);
                if (area > max){
                    max = area;
                }
            }
        }
        return max;
    }
}